HTMLify
index.html
Views: 465 | Author: cody
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>3D Rotating Geometry Shape Using Three.js</title> <meta name="viewport" content="width=device-width, initial-scale=1" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r50/three.min.js"></script> <link rel="stylesheet" type="text/css" media="screen" href="style.css" /> </head> <body> <script> if (window.innerWidth === 0) { window.innerWidth = parent.innerWidth; window.innerHeight = parent.innerHeight; } var camera, scene, renderer; var geometry, material, mesh; init(); animate(); function init() { camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 2, 1000 ); camera.position.z = 400; scene = new THREE.Scene(); geometry = new THREE.IcosahedronGeometry(100, 1); material = new THREE.MeshBasicMaterial({ color: 0xff3399, wireframe: true, wireframeLinewidth: 3, }); mesh = new THREE.Mesh(geometry, material); scene.add(mesh); renderer = new THREE.CanvasRenderer(); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); } function animate() { requestAnimationFrame(animate); mesh.rotation.x += 0.03; mesh.rotation.y += 0.02; renderer.render(scene, camera); } </script> </body> </html> |